<template>
    <div class="collect-configuration">
        <div class="personal-center-title"><h3>采集号配置信息</h3></div>
        <div class="collect-configuration-area" v-for="key in data">
            <ul>
                <li>
                    <div>配置类型</div>
                    <div>中航信eTerm</div>
                    <div>eTerm端口</div>
                    <div>{{key.info.etermPort}}</div>
                </li>
                <li>
                    <div>用户名</div>
                    <div>{{key.info.user}}</div>
                    <div>si指令</div>
                    <div>*********</div>
                </li>
                <li>
                    <div>密码</div>
                    <div>*********</div>
                    <div>自动采集时间（h）</div>
                    <div>{{key.info.acquisitionT}}</div>
                </li>
                <li>
                    <div>工作号</div>
                    <div>{{key.info.jobn}}</div>
                    <div>冲突等待时间（m）</div>
                    <div>{{key.info.conflict}}</div>
                </li>
                <li>
                    <div>工作号密码</div>
                    <div>*********</div>
                    <div>最后更新时间</div>
                    <div>{{key.info.lastTime}}</div>
                </li>
                <li>
                    <div>级别</div>
                    <div>{{key.info.level}}</div>
                    <div>状态</div>
                    <div v-if="key.info.state==0">请测试</div>
                    <div v-else-if="key.info.state==1">正常</div>
                    <div v-else-if="key.info.state==2">密码错误</div>
                </li>
                <li>
                    <div>eTermIP</div>
                    <div>{{key.info.etermIp}}</div>
                    <div class="click-btn">
                        <span class="click-btn-test" @click="testConnect(key.info.id)">测试连接</span>
                    </div>
                </li>
            </ul>
            <div>
                <div class="collect-change"  @click="amend(key)"></div>
                <div class="collect-clear" @click="deletes(key.info.id)">
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    export default{
        data(){
            return{
                data:''
            }
        },
        props:['up_date'],
        watch:{
            up_date:function () {
                this.req();
            }
        },
        mounted:function () {
            this.req();
        },
        methods:{
            req:function () {
                $.ajax({
                    type:'post',
                    url:'/getEtermAirportOnLineData',
                    dataType:'json',
                    success:(data)=>{
                        this.data=data;
                    }
                })
            },
            testConnect:function (val) {
                this.$emit('test_etermId',val);
            },
            deletes:function (val) {
               if(confirm("确认要删除？")){
                   $.ajax({
                       type:'get',
                       data:{
                           id:val
                       },
                       dataType:'json',
                       url:"/eterm_delete",
                       success:(data)=>{
                           if(data.success){
                               this.req();
                           }else{
                               alert("删除失败");
                           }
                       }
                   });
               }
            },
            amend:function (val) {
                this.$emit('amend',val);
            }
        }
    }
</script>
<style>

</style>